

import graphics.BootColor;

import javax.microedition.lcdui.Graphics;

public class MatricialKeyboard {

	private static final int H_GAP = 25;
	private static final int V_OFFSET = 100;
	private static final int H_OFFSET = 70;
	private static final int NUM_COL = 6;
	private static final char[] CHAR_LIST = new char[] { 'a', 'b', 'c', 'd',
			'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
			'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };

	public void repaint(Graphics g) {
		int fHeight = g.getFont().getHeight();
		g.setColor(BootColor.BLUE);

		for (int i = 0; i < NUM_COL; i++) {
			g.drawString("" + (i + 1), H_OFFSET + i * H_GAP, V_OFFSET,
					Graphics.RIGHT | Graphics.BOTTOM);
		}

		int curChar = 0;
		int line = 0;

		while (curChar < CHAR_LIST.length - 1) {
			int linePos = curChar % NUM_COL;
			if (linePos == 0) {
				line++;
				int lineNum = curChar / NUM_COL + 1;
				g.setColor(BootColor.BLUE);
				g.drawString("" + lineNum, H_OFFSET + (linePos - 1) * H_GAP, V_OFFSET
						+ line * fHeight, Graphics.RIGHT | Graphics.BOTTOM);
			}

			g.setColor(BootColor.WHITE);
			g.drawString("" + CHAR_LIST[curChar], H_OFFSET + linePos * H_GAP, V_OFFSET
					+ line * fHeight, Graphics.RIGHT | Graphics.BOTTOM);
			curChar++;
		}
	}

}
